/**
 * Copyright &copy; 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.ffzx.commerce.framework.system.entity;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.validator.constraints.Length;

import com.ffzx.commerce.framework.common.persistence.TreeEntity;

/**
 * 区域Entity
 * @author tangshifeng
 * @version 2016-03-3
 */
public class SysArea extends TreeEntity<SysArea> {

	private static final long serialVersionUID = 1L;
	@Length(min=0, max=50)
	private String code; 	// 区域编码
	@Length(min=1, max=1,message="请选择区域类型")
	private String type; 	// 区域类型（1：国家；2：省份、直辖市；3：地市；4：区县）
	private List<SysArea> sub;
	
	public SysArea(){
		super();
		//this.sort = 30;
	}

	public SysArea(String id){
		super(id);
	}
	
	public SysArea getParent() {
		return parent;
	}

	public void setParent(SysArea parent) {
		this.parent = parent;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}
	
	@Override
	public String toString() {
		return name;
	}

	public List<SysArea> getSub() {
		if (sub == null){
			sub = new ArrayList<SysArea>();
		}
		return sub;
	}

	public void setSub(List<SysArea> sub) {
		this.sub = sub;
	}

}